package tv.geir.slackspace.communication;

import java.io.Serializable;

import net.jini.id.Uuid;

/**
 * 
 * Represents a response to a request
 * 
 * @author Geir Gullestad Pettersen
 *
 */
public class Response implements Serializable{
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private Response.Code responseCode;
	private Serializable data;	
	private Throwable error;
	private Uuid responseTo;
	
	public Response( Uuid responseTo ) {
		this.responseTo = responseTo;
	}
	
	/**
	 * @param responseCode
	 * @param responseTo
	 */
	public Response( Response.Code responseCode , Uuid responseTo) {
		this( responseCode, responseTo, null );
	}
	
	/**
	 * @param responseCode
	 * @param responseTo
	 * @param data
	 */
	public Response( Response.Code responseCode, Uuid responseTo, Serializable data ) {
		this.responseCode = responseCode;
		this.data=data;
		this.responseTo = responseTo;
	}

	public Serializable getData() {
		return data;
	}

	public void setData(Serializable data) {
		this.data = data;
	}

	public Response.Code getResponseCode() {
		return responseCode;
	}

	public void setResponseCode(Response.Code responseCode) {
		this.responseCode = responseCode;
	}

	public enum Code implements Serializable{
		OK, ERROR, SHUTDOWN, EVENT;
	}

	public Uuid getResponseTo() {
		return responseTo;
	}

	public void setResponseTo(Uuid responseTo) {
		this.responseTo = responseTo;
	}

	public Throwable getError() {
		return error;
	}

	public void setError(Throwable error) {
		this.error = error;
	}
	
}
